package flc.ast;

import android.view.View;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.ScreenUtils;

import java.util.ArrayList;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.AvatarFragment;
import flc.ast.fragment.ExpressFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.event.IEventStat;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {


    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
        mDataBinding.llHomeBottom.setOnClickListener(null);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment=new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class,R.id.ivHome));
        listFragment.add(new FragmentViewBinder(ExpressFragment.class,R.id.ivExpress));
        listFragment.add(new FragmentViewBinder(AvatarFragment.class,R.id.ivAvatar));
        listFragment.add(new FragmentViewBinder(MyFragment.class,R.id.ivMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        switch (view.getId()){
            case R.id.ivHome:
                mDataBinding.ivHome.setImageResource(R.drawable.axiangjih);
                break;
            case R.id.ivExpress:
                mDataBinding.ivExpress.setImageResource(R.drawable.amanhuazixun);
                break;
            case R.id.ivAvatar:
                mDataBinding.ivAvatar.setImageResource(R.drawable.abizhitoux);
                break;
            case R.id.ivMy:
                mDataBinding.ivMy.setImageResource(R.drawable.awode);
                break;
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.axjmh);
        mDataBinding.ivExpress.setImageResource(R.drawable.azixun);
        mDataBinding.ivAvatar.setImageResource(R.drawable.atuku);
        mDataBinding.ivMy.setImageResource(R.drawable.awod);
    }

}